package org.example.nebula.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.nebula.entity.input.ExportEdgeInput;
import org.example.nebula.entity.input.ExportNodeInput;
import org.example.nebula.entity.out.Result;
import org.example.nebula.service.ExportDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author: jszhang
 * @date: 2025/10/26-11:43
 */
@Api(tags = "导出图谱数据")
@Slf4j
@RestController
@RequestMapping("/data/export")
public class ExportDataController {

    @Autowired
    private ExportDataService exportDataService;

    @ApiOperation("导出指定节点")
    @RequestMapping(value = "/node", method = RequestMethod.POST)
    public Result<?> exportNode2Csv(@Valid @RequestBody ExportNodeInput input) {
        exportDataService.exportNode2Csv(input);
        return Result.OK();
    }

    @ApiOperation("导出指定关系")
    @RequestMapping(value = "/edge", method = RequestMethod.POST)
    public Result<?> exportEdge2Csv(@Valid @RequestBody ExportEdgeInput input) {
        exportDataService.exportEdge2Csv(input);
        return Result.OK();
    }

}
